Merged
Conversation
…deadcode when WOLF_PRIVATE_KEY_ID enabled
remove comment
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies a set of targeted Coverity-driven hardening fixes across wolfCrypt’s HPKE and ASN.1/PEM/CRL encoding/decoding paths to eliminate dead code, prevent unsafe casts, and add bounds checks.
Changes:
- HPKE: tighten
I2OSP()validation by rejecting negative inputs and removing a dead/ineffective upper-bound check. - ASN.1: add a temporary-buffer bounds check for RSA-PSS AlgoId encoding and simplify a redundant
NULLcheck after prior argument validation. - PEM/CRL: preserve the original PEM “type” across internal remapping and prevent negative return values from being cast to
word32during CRL encoding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| wolfcrypt/src/hpke.c | Adjusts I2OSP() validation to address Coverity findings (negative input handling, remove dead check). |
| wolfcrypt/src/asn.c | Adds RSA-PSS temp-buffer bounds check, simplifies RSA public key decode index reset, preserves original PEM type, and fixes CRL size casting issues. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
douzzer
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Addresses CIDs
WOLF_PRIVATE_KEY_IDoverwrites type if enabled)intvariable to catch negative value before casting toword32NULLcheckn < 0and returnsMP_VALif true. removesn > 0x7fffffffcheck.hashAlgSz > RSA_PSS_ALGOID_TMPBUF_SZbefore callingXMEMCPY()Testing
./configure --enable-all && make checkChecklist